<?php

  /*---------------------------------------------------------------------------------*/
 /* Social widget 																	*/
/*---------------------------------------------------------------------------------*/
class Nice_Social extends WP_Widget {

	function __construct() {
		$widget_ops = array( 'description' => __( 'Add your social links with this widget. (Note: To set the social links you have to do it on the theme options panel.)', 'nicethemes' ) );
		parent::__construct(false, __( '(NiceThemes) Social Widget', 'nicethemes' ), $widget_ops);
	}

	function widget( $args, $instance) {
	extract( $args );
	$title = $instance['title'];
	$unique_id = $args['widget_id'];
	global $nice_options;
	?>
		<?php echo $before_widget; ?>
		<?php if ( $title ) echo $before_title . $title . $after_title; ?>
		<?php

					$social_items = '';

					if ( $nice_options["nice_facebook_url"] != '' ) $social_items .= '<li class="facebook"><a href="' . esc_url( $nice_options["nice_facebook_url"] ) . '"></a></li>';
					if ( $nice_options["nice_twitter_url"] != '' ) 	$social_items .= '<li class="twitter"><a href="' . esc_url( $nice_options["nice_twitter_url"] ) . '"></a></li>';
					if ( $nice_options["nice_fivehundredpx_url"] != '' ) $social_items .= '<li class="fivehundredpx"><a href="' . esc_url( $nice_options["nice_fivehundredpx_url"] ) . '"></a></li>';
					if ( $nice_options["nice_devianart_url"] != '' ) $social_items .= '<li class="devianart"><a href="' . esc_url( $nice_options["nice_devianart_url"] ) . '"></a></li>';
					if ( $nice_options["nice_youtube_url"] != '' ) 	$social_items .= '<li class="youtube"><a href="' . esc_url( $nice_options["nice_youtube_url"] ) . '"></a></li>';
					if ( $nice_options["nice_dribbble_url"] != '' ) $social_items .= '<li class="dribbble"><a href="' . esc_url( $nice_options["nice_dribbble_url"] ) . '"></a></li>';
					if ( $nice_options["nice_zerply_url"] != '' )   $social_items .= '<li class="zerply"><a href="' . esc_url( $nice_options["nice_zerply_url"] ) . '"></a></li>';
					if ( $nice_options["nice_skype_url"] != '' )	$social_items .= '<li class="skype"><a href="' . esc_url( $nice_options["nice_skype_url"] ) . '"></a></li>';
					if ( $nice_options["nice_android_url"] != '' )  $social_items .= '<li class="android"><a href="' . esc_url( $nice_options["nice_android_url"] ) . '"></a></li>';
					if ( $nice_options["nice_envato_url"] != '' ) 	$social_items .= '<li class="envato"><a href="' . esc_url( $nice_options["nice_envato_url"] ) . '"></a></li>';
					if ( $nice_options["nice_instagram_url"] != '' ) $social_items .= '<li class="instagram"><a href="' . esc_url( $nice_options["nice_instagram_url"] ) . '"></a></li>';
					if ( $nice_options["nice_apple_url"] != '' ) 	$social_items .= '<li class="apple"><a href="' . esc_url( $nice_options["nice_apple_url"] ) . '"></a></li>';
					if ( $nice_options["nice_linkedin_url"] != '' ) $social_items .= '<li class="linkedin"><a href="' . esc_url( $nice_options["nice_linkedin_url"] ) . '"></a></li>';
					if ( $nice_options["nice_squarespace_url"] != '' ) $social_items .= '<li class="squarespace"><a href="' . esc_url( $nice_options["nice_squarespace_url"] ) . '"></a></li>';
					if ( $nice_options["nice_flickr_url"] != '' ) 	$social_items .= '<li class="flickr"><a href="' . esc_url( $nice_options["nice_flickr_url"] ) . '"></a></li>';
					if ( $nice_options["nice_path_url"] != '' ) 	$social_items .= '<li class="path"><a href="' . esc_url( $nice_options["nice_path_url"] ) . '"></a></li>';
					if ( $nice_options["nice_tumblr_url"] != '' ) 	$social_items .= '<li class="tumblr"><a href="' . esc_url( $nice_options["nice_tumblr_url"] ) . '"></a></li>';
					if ( $nice_options["nice_behance_url"] != '' ) 	$social_items .= '<li class="behance"><a href="' . esc_url( $nice_options["nice_behance_url"] ) . '"></a></li>';
					if ( $nice_options["nice_forrst_url"] != '' ) 	$social_items .= '<li class="forrst"><a href="' . esc_url( $nice_options["nice_forrst_url"] ) . '"></a></li>';
					if ( $nice_options["nice_paypal_url"] != '' )   $social_items .= '<li class="paypal"><a href="' . esc_url( $nice_options["nice_paypal_url"] ) . '"></a></li>';
					if ( $nice_options["nice_foursquare_url"] != '' ) $social_items .= '<li class="foursquare"><a href="' . esc_url( $nice_options["nice_foursquare_url"] ) . '"></a></li>';
					if ( $nice_options["nice_pinterest_url"] != '' ) $social_items .= '<li class="pinterest"><a href="' . esc_url( $nice_options["nice_pinterest_url"] ) . '"></a></li>';
					if ( $nice_options["nice_github_url"] != '' ) 	$social_items .= '<li class="github"><a href="' . esc_url( $nice_options["nice_github_url"] ) . '"></a></li>';
					if ( $nice_options["nice_quora_url"] != '' ) 	$social_items .= '<li class="quora"><a href="' . esc_url( $nice_options["nice_quora_url"] ) . '"></a></li>';
					if ( $nice_options["nice_vimeo_url"] != '' ) 	$social_items .= '<li class="vimeo"><a href="' . esc_url( $nice_options["nice_vimeo_url"] ) . '"></a></li>';
					if ( $nice_options["nice_designmoo_url"] != '' ) $social_items .= '<li class="designmoo"><a href="' . esc_url( $nice_options["nice_designmoo_url"] ) . '"></a></li>';
					if ( $nice_options["nice_google_url"] != '' ) 	$social_items .= '<li class="google"><a href="' . esc_url( $nice_options["nice_google_url"] ) . '"></a></li>';
					if ( $nice_options["nice_wordpress_url"] != '' ) $social_items .= '<li class="wordpress"><a href="' . esc_url( $nice_options["nice_wordpress_url"] ) . '"></a></li>';

				if ( ! empty ( $social_items ) ) :
				?>

				<div class="social-links clearfix">

					<ul class="social">
						<?php echo $social_items; ?>
					</ul>

				</div>
				<?php endif; ?>
		<?php echo $after_widget; ?>


	<?php
	}

	function update( $new_instance, $old_instance) {
		return $new_instance;
	}

	function form( $instance) {

		$title = esc_attr( $instance['title']);
		?>
		<p>
			<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title (optional):', 'nicethemes' ); ?></label>
			<input type="text" name="<?php echo $this->get_field_name('title'); ?>"  value="<?php echo $title; ?>" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" />
		</p>
		<?php
	}

}
register_widget( 'Nice_Social' );
?>